package com.dbpms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

// 配置文件上传 - MultipartResolver
@Configuration
public class MultipartConfig {
    @Bean
    public CommonsMultipartResolver multipartResolver() {
        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
        // 设置最大上传文件大小为10MB
        resolver.setMaxUploadSize(10485760);
        // 设置内存中的最大文件大小，单位为字节（40960=40KB）
        resolver.setMaxInMemorySize(40960);
        // 设置编码
        resolver.setDefaultEncoding("UTF-8");
        return resolver;
    }
}